 <script type="text/javascript">
$(function () {
	var url = '${contextPath}script/oa/reimburse.js';
	$.ajax({url:url, dataType:'script', cache:true,
		success: function(){
			
		}
	});
});
function countTotalPrice() {
	var cou,total = 0, thiss;
	$('#detailListBody tr.rep').each(function() {
		thiss = $(this);
		cou = thiss.find('input.cou').val();
		total = parseFloat(total) + parseFloat(cou);
	});
	$('#total').val(total.toFixed(2));
}
</script>

<#import "/freemarker/modeltype.ftl" as mt>
<#import "/freemarker/modeltype_entity.ftl" as mte>
<div class="widget-header">
		<h3 class="title"><i class="fontello-icon-th-list-1"></i> 编辑申请信息</h3>
</div>
<div class="widget" >
	<div class="widget-content">
		<form id="editForm">
			<table class="table table-bordered animate2 fadeInUp" style="width:400px; text-align:left;">
				<tr>
					<th class="table-left" style="width:60px;">标题</th>
					<td><input type="text" id="title" name="title" value="${(reimburse.title)!''}" placeholder="标题可自动生成 无需填写"/>
						<input type="hidden" id="code" name="code" value="${(reimburse.code)!''}" />
						<input type="hidden" id="pass" name="pass" value="${(reimburse.pass)!''}" />
					</td>
				</tr>
				<tr>
					<th class="table-left" style="width:60px;">总金额</th>
					<td><input type="text" id="total" name="total" value="${(reimburse.total)!''}"/></td>
				</tr>
				<tr>
					<th class="table-left" style="width:60px;">大写</th>
					<td><input type="text" id="capital" name="capital" value="${(reimburse.capital)!''}"/></td>
				</tr>
				<tr>
					<th class="table-left" style="width:60px;">备注</th>
					<td><textarea type="text" id="remark" name="remark">${(reimburse.remark)!''}</textarea></td>
				</tr>
			</table>
			<table style="width:400px; margin-top:10px;" class="table table-bordered animate2 fadeInUp">
				<thead>
					<tr>
						<th style="text-align:center; width:120px;">报销项目<a href="javascript:;" onclick="javascript:addDetail_reimburse();return false;" style="margin-left: 20px">[添加空白行]</a></th>
						<th style="text-align:center; width:200px;">类别<a href="javascript:;" onclick="javascript: add_reimburse();return false;" style="margin-left: 20px">[添加类别]</a></th>
						<th style="text-align:center; width:40px;">金额</th>
						<th style="text-align:center; width:60px;">票据数量</th>
						<th style="text-align:center;">费用明细</th>
						<th style="width:32px;">操作</th>
					</tr>
				</thead>
				<tbody id="detailListBody">
					<#assign i = 0 />
					<#if ((reimburse.itemList)?? && reimburse.itemList?size > 0)>
						<#list reimburse.itemList as item>
						<tr class="rep">
							<td><input type="text" name="itemList[${i}].project" value="${(item.project)!''}" class="project not-null" onblur="javascript:createTitle_reimburse();return false;" readonly/>
								<input type="hidden" name="itemList[${i}].code" value="${(item.code)!''}" />
							</td>
							<td>
								<div class="input-group" style="width: 180px;">
									<input class="rcn" id="rcn_${i}" name="itemList[${i}].rcn" type="text" style="width:120px;" value="${(item.rcn)!''}" readonly />
									<input class="rcc not-null" id="rcc_${i}" name="itemList[${i}].rcc" type="hidden" value="${(item.rcc)!''}"/>
									<button class="btn btn-xs btn-primary" pib="${i}" onclick="javascript: select_reimburse($(this));return false;" type="button"><i class="icon-search"></i></button>
								</div>
							</td>
							<td><input class="cou not-null" type="text" name="itemList[${i}].amount" value="${(item.amount)!''}" onblur="javascript:createTitle_reimburse();countTotalPrice();return false;" style="width:40px;"/></td>
							<td><input class="u" type="text" name="itemList[${i}].num" value="${(item.num)!''}" onblur="javascript:createTitle_reimburse();return false;" style="width:60px;"/></td>
							<td><textarea class="re" name="itemList[${i}].remark" value="${(item.remark)!'无'}">${(item.remark)!'无'}</textarea></td>
							<td style="text-align:center;"><a class="btn btn-danger" href="javascript:;" onclick="javascript:delete_reimburse($(this));return false;"><i class="icon-remove"></i></a></td>
						</tr>
						<#assign i = i + 1/></#list>
					<#else>
					<tr class="rep">
						<td><input type="text" name="itemList[${i}].project" class="project not-null" onblur="javascript:createTitle_reimburse();return false;"/></td>
						<td>
							<div class="input-append">
								<input class="rcn" id="rcn_${i}" name="itemList[${i}].rcn" type="text" style="width:120px;" readonly/>
								<input class="rcc not-null" id="rcc_${i}" name="itemList[${i}].rcc" type="hidden" />
								<button class="btn btn-xs btn-primary" pib="${i}" type="button" onclick="javascript: select_reimburse($(this));return false;"><i class="icon-search"></i></button>
							</div>
						</td>
						<td><input class="cou not-null" type="text" name="itemList[${i}].amount" style="width:40px;" onblur="javascript:createTitle_reimburse();countTotalPrice(); return false;"/></td>
						<td><input class="u not-null" type="text" name="itemList[${i}].num" onblur="javascript:createTitle_reimburse();return false;" style="width:60px;"/></td>
						<td><textarea class="re" name="itemList[${i}].remark" value="${(item.remark)!''}" style="height: 37px;"/></td>
						<td style="text-align:center;"><a class="btn btn-danger" href="javascript:;" onclick="javascript:delete_reimburse($(this));return false;"><i class="icon-remove"></i></a></td>
					</tr>
					<#assign i = i + 1/></#if>
				</tbody>
				<tr>
					<td colspan="5" style="text-align:center;">
						<a class="btn btn-info" href="javascript:;" onclick="javascript: save_reimburse();return false;"><i class="icon-save"></i> 保 存</a>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<a class="btn btn-primary" href="javascript:;" onclick="javascript:sys_load_handle('reimburse');return false;"><i class="icon-block"></i> 取 消</a>
					</td>
				</tr>
			</table>
		</form>
	</div>
</div>
<input type="hidden" id="index" value="${i}" />
<table id="tempTable" style="display:none;">
	<tr class="rep">
		<td><input class="project" type="text" onblur="javascript:createTitle_reimburse();"/></td>
		<td>
			<div class="input-append">
				<input class="rcn " type="text" style="width:120px;" readonly />
				<input class="rcc not-null" type="hidden" />
				<button class="btn btn-xs btn-primary" type="button" onclick="javascript: select_reimburse($(this));return false;"><i class="icon-search"></i></button>
			</div>
		</td>
		<td><input class="cou" type="text" style="width:40px;" onblur="javascript:createTitle_reimburse();countTotalPrice(); " /></td>
		<td><input class="u" type="text" style="width:60px;" onblur="javascript:createTitle_reimburse(); return false;"/></td>
		<td><textarea class="re" style="height: 37px;"/></td>
		<td style="text-align:center;"><a class="btn btn-danger" href="javascript:;" onclick="javascript:delete_reimburse($(this));return false;"><i class="icon-remove"></i></a></td>
	</tr>
</table>
